import request from '@/utils/request'
import type { Attr, AttrResponseData, CategoryResponseData } from './type'
//接口地址
enum API {
  C1_URL = '/admin/product/getCategory1',
  C2_URL = '/admin/product/getCategory2/',
  C3_URL = '/admin/product/getCategory3/',
  ATTR_URl = '/admin/product/attrInfoList/',
  ADDUPDATA_ATTR_URL = '/admin/product/saveAttrInfo',
  DELETE_ATTR_URL = '/admin/product/deleteAttr/',
}
//获取分类1列表
export const reqC1 = () => request.get<any, CategoryResponseData>(API.C1_URL)
//获取分类2列表 需要分类1内的id
export const reqC2 = (categoryId1: number | string) =>
  request.get<any, CategoryResponseData>(API.C2_URL + categoryId1)
//获取分类3列表 需要分类2内的id
export const reqC3 = (categoryId2: number | string) =>
  request.get<any, CategoryResponseData>(API.C3_URL + categoryId2)
export const reqAttr = (
  categoryId1: number | string,
  categoryId2: number | string,
  categoryId3: number | string,
) =>
  request.get<any, AttrResponseData>(
    API.ATTR_URl + `${categoryId1}/${categoryId2}/${categoryId3}`,
  )
//新增或修改属性
export const AddUpdataAttr = (data: Attr) =>
  request.post(API.ADDUPDATA_ATTR_URL, data)
//删除属性
export const DeleteAttr = (attrId: number) =>
  request.delete<any, any>(API.DELETE_ATTR_URL + attrId)
